<?
/*头部初始函数*/
function rcodestr($prc,$rnum){
  if ($prc==$rnum) {
    $rcstr="class='act'";
    }else{
    $rcstr="";
    }
    return $rcstr;
}

$page_r_code=1;
if (strpos($_SERVER['PHP_SELF'],'/flight')===0) $page_r_code=4;
if (strpos($_SERVER['PHP_SELF'],'/jq/')===0) $page_r_code=2;
if (strpos($_SERVER['PHP_SELF'],'/jq/news')===0) $page_r_code=7;
if (strpos($_SERVER['PHP_SELF'],'/biz/')===0) $page_r_code=1;
if (strpos($_SERVER['PHP_SELF'],'/f/')===0) $page_r_code=9;

if (strpos($_SERVER['PHP_SELF'],'/d/')===0) {
	if ($_SERVER['HTTP_HOST']!='www.16u.cc') {
		echo "<script>window.location.href='http://www.16u.cc".$_SERVER['REQUEST_URI']."'</script>";
		exit;
	}
	$page_r_code=8;
	$logoimg=1;
}else{
	$logoimg="";
}

if (c_get($page_r_code)){
echo "<script>alert('非法操作！$page_r_code'); window.location='/';</script>";
echo "非法操作！";
exit;
}

$_w["title1"]=" | 一路游，好风景";
$_w["title"]=" 先行网".$_w["title1"];

$user_l_txt1=$user_l_txt2="&nbsp;&nbsp;&nbsp;&nbsp;";

$user_l_txt1.="<a href='/p'><img src='".$host."/images/member2.png' class='imgie6' align='absmiddle' border='0' /></a>&nbsp;";
if ($_SESSION["uu_id"]) {
	$user_l_txt1.="<a href='".$host."/p'>我的16U<img src='".$host."/images/arrow1.png' align='absmiddle' class='imgie6' /></a>&nbsp;&nbsp;";
	$logoutID=3;
}elseif ($_SESSION["uu_mid"]) {
	$user_l_txt1.="<a href='".$host."/biz'>商户中心<img src='".$host."/images/arrow1.png' align='absmiddle' class='imgie6' /></a>&nbsp;&nbsp;";
    $logoutID=6;
}

$user_l_txt1.="<a href='".$host."/logout.html?id=".$logoutID."'>退出<img src='".$host."/images/arrow1.png' align='absmiddle' class='imgie6' /></a>&nbsp;&nbsp;";

$user_l_txt2.="<img src='".$host."/images/member1.png' class='imgie6' align='absmiddle' />&nbsp;";
$user_l_txt2.="<a href='".$host."/login'>登录<img src='".$host."/images/arrow1.png' align='absmiddle' class='imgie6' /></a>&nbsp;&nbsp;";
$user_l_txt2.="<a href='".$host."/reg'>注册<img src='".$host."/images/arrow1.png' align='absmiddle' class='imgie6' /></a>&nbsp;&nbsp;";	


if (($_SESSION['uu_user'] && $_SESSION['uu_id']) || $_SESSION['uu_mid']) $user_l_txt=$user_l_txt1;
else $user_l_txt=$user_l_txt2;

$phpself=$_SERVER['PHP_SELF'];

if (strstr($phpself,'/jq/news')) {
   $pgID=5;
}elseif (strstr($phpself,'/line/')){
   $pgID=2;
}elseif (strstr($phpself,'/hotel/')){
   $pgID=3;
}elseif (strstr($phpself,'/jq/')){
   $pgID=1;
}elseif (strstr($phpself,'/f/')){
   $pgID=6;
}else{
   $pgID=4;
}
	
$str="select dtitle,keywords,description from uu_webconfig where id='".$pgID."'";
$GLOBALS['le']->query($str);
$GLOBALS['le']->fetch_assoc();
$d_title1=$GLOBALS['le']->f('dtitle');
$d_keywords=$GLOBALS['le']->f('keywords');
$d_description=$GLOBALS['le']->f('description');


preg_match('/s_.+?\.html/',$phpself,$ajqid);
$jqid=str_replace(array("s_",".html"),"",$ajqid[0]);

$str="select dtitle,keywords,description from uu_land where id='".$jqid."'";
$GLOBALS['le']->query($str);
if ($GLOBALS['le']->fetch_assoc()){
$d_title1=$GLOBALS['le']->f('dtitle');
$d_keywords=$GLOBALS['le']->f('keywords');
$d_description=$GLOBALS['le']->f('description');

}

$d_title=$d_title1;
//处理页面访问记录
$rurl=htmlspecialchars($_SERVER['HTTP_REFERER']);
$durl=htmlspecialchars($_SERVER['REQUEST_URI']);
$dtitle2=htmlspecialchars($d_title1);
$dip=$_SERVER['REMOTE_ADDR'];
//$str="insert uu_pageview set rurl='$rurl',durl='$durl',dtitle='$dtitle2',dip='$dip',ddate=now()";
//$GLOBALS['le']->query($str);

$arr_host=array('b.16u.com','zhifu.crh001.com','app.crh001.com');
if (in_array($_SERVER['HTTP_HOST'],$arr_host)){
//这里处理对外合作
$co_signal=$_REQUEST['ccid'];
$a_coop_code=array('1','101'=>'sm','201'=>'lc','301'=>'ft','401'=>'te','501'=>'zl','601'=>'dc');
$a_b_title=array('1','101'=>'神州数码','201'=>'车翼行','301'=>'福建旅游资讯网','401'=>'台儿庄古城','501'=>'中旅驿家','601'=>'动车杂志');
$a_coop=array_keys($a_coop_code);

if (!in_array($co_signal,$a_coop) && !$_SESSION['cosignal']) die("无此商户");
//$co_signal=$co_signal?$co_signal:1;
//if (c_get($co_signal)) die("非法变量");
if (!$_SESSION['cosignal']) $_SESSION['cosignal']=$co_signal;
elseif ($co_signal) $_SESSION['cosignal']=$co_signal;

if (!$_REQUEST['uid'] && !$_SESSION['uu_id']) die("参数UID错误");
//echo $_SESSION['uu_id'];
if (!$_SESSION['uu_id'] && $_REQUEST['uid']) {
	//$_SESSION['uu_id']='sm'.$_REQUEST['uid'];
if (p_match($_REQUEST['uid'])) die("非法参数请修改");
$co_num_s=(string)$co_signal;
$hash_name=hashN($co_num_s{2});

$str="select id from uu_co_member where ccode='".$a_coop_code[$co_signal]."' and $hash_name='".$_REQUEST['uid']."'";
$GLOBALS['le']->query($str);
$GLOBALS['le']->fetch_assoc();
$CO_id=$GLOBALS['le']->f('id');
//echo "1:".$str;
if (!$CO_id){
$str="insert uu_co_member set ccode='".$a_coop_code[$co_signal]."',$hash_name='".$_REQUEST['uid']."',addtime=now()";
$GLOBALS['le']->query($str);
$CO_id=mysql_insert_id();	
}


$str="select did from uu_member where co='".$a_coop_code[$co_signal].$CO_id."'";
$GLOBALS['le']->query($str);
$GLOBALS['le']->fetch_assoc();
//echo "2:".$str;
$CO_did=$GLOBALS['le']->f('did');
//if (!$CO_did) die("会员系统出错！请联系网站管理人员");

if (!$CO_did){
//自动生成会员
$pp=$_SERVER['REQUEST_TIME'];
$pp1=substr($pp,0,5);
$pp2=substr($pp,5,5);
$zf="ABCDEFGHJKT";
$zf_n=rand(0,9);
$pp="X".$pp1.$zf{$zf_n}.$pp2;
$pw=md5(md5('x81010t987'));
$str="insert uu_member set passport='$pp',password='$pw',co='".$a_coop_code[$co_signal].$CO_id."',create_time=now()";
$GLOBALS['le']->query($str);
$CO_did=mysql_insert_id();
}

$_SESSION['uu_id']=$CO_did;
}

$mod_path=$root."/mod_head/thead".$_SESSION['cosignal'].".php";
$mod_path2=$root."/mod_head/tfoot".$_SESSION['cosignal'].".php";
if (!file_exists($mod_path)) die("无此商户");
$_w["title"]=$a_b_title[$_SESSION['cosignal']].$_w["title1"];
}elseif($_SERVER['HTTP_HOST']=='fx.16u.com' || $_SERVER['HTTP_HOST']=='www.16u.cc'){
$mod_path=$root."/mod_head/thead_fx.php";
$mod_path2=$root."/mod_head/tfoot_fx.php";
}else{
$mod_path=$root."/mod_head/main.php";
$mod_path2=$root."/mod_head/mainfoot.php";
}

//处理单点登录
if ($_REQUEST['xu']){
$xu=trim($_REQUEST['xu']);
$str_xu1=substr($xu,-1,1);
$str_xu2=substr($xu,0,32);
if ($str_xu1=='0') {
	$str="select did,mobile from uu_member where md5(concat(did,password,last_time))='$str_xu2' and md5(concat(did,password,last_time)) is not null limit 1";
	$GLOBALS['le']->query($str);
    if ($GLOBALS['le']->fetch_assoc()) {
	  $_SESSION['uu_id']=$GLOBALS['le']->f('did');
	  $_SESSION['uu_user']=$GLOBALS['le']->f('mobile');
    }
}elseif($str_xu1=='1') {
	$str="select id from uu_distributor where md5(concat(id,password,lasttime))='$str_xu2' and md5(concat(id,password,lasttime)) is not null limit 1";
	$GLOBALS['le']->query($str);
    if ($GLOBALS['le']->fetch_assoc()) {
	  $_SESSION['uu_mid']=$GLOBALS['le']->f('id');
    }	
}
}
?>